#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* typedef enum { false, true } bool; */
#define MIN(x, y)	((x) < (y) ? (x) : (y))
#define MAX(x, y)	((x) > (y) ? (x) : (y))

typedef struct Node {
	long long sum;
	long long val;
	bool valid_val;
	int l;
	int r;
	struct Node *left;
	struct Node *right;
} Node;


Node *
init(int l, int r)
{
	int mid;
	Node *node;

	node = (Node*) malloc(sizeof(Node));
	node->l         = l;
	node->r         = r;
	node->sum       = 0LL;
	node->val       = 0LL;
	node->valid_val = true;

	if (l != r) {
		mid = (l + r)/2;
		node->left  = init(l, mid);
		node->right = init(mid+1, r);
	} else {
		node->left  = NULL;
		node->right = NULL;
	}
	return node;
}

void
set_node_val(Node *node, long long val)
{
/*	if (val)
		(void) fprintf(stderr, "set_node_val(): assigning val=%lld "
				"to node=<%6d,%6d,%5s>\n",
				val, node->l, node->r,
				node->valid_val ? "true" : "false");*/
	node->val       = val;
	node->valid_val = true;
	node->sum       = val * (node->r - node->l + 1);
}

/*
 * Requirements:
 * node->l <= l
 * node->r >= r
 */
void
set(Node *node, int l, int r, long long val)
{
	if (node->l == l && node->r == r)
		return set_node_val(node, val);
	if (node->valid_val) {
		node->valid_val = false;
		set_node_val(node->left,  node->val);
		set_node_val(node->right, node->val);
	}
	if (r <= node->left->r)
		set(node->left,  l, MIN(r, node->left->r), val);
	else if (l >= node->right->l)
		set(node->right, MAX(l, node->right->l), r, val);
	else {
		set(node->left,  l, node->left->r,  val);
		set(node->right, node->right->l, r, val);
	}
	node->sum = node->left->sum + node->right->sum;
}

long long
sum(Node *node, int l, int r)
{
	if (l > r) {
/*		(void) fprintf(stderr, "sum(node=%016p, l=%d, r=%d): "
			"l > r, returning 0LL\n",
			node, l, r);*/
		return 0LL;
	}
	if (l == node->l && r == node->r) {
/*		(void) fprintf(stderr, "sum(node=%016p, l=%d, r=%d): "
			"полностью покрывает отрезок [l;r]\n",
			node, l, r);*/
		return node->sum;
	}
	if (node->valid_val) {
/*		(void) fprintf(stderr, "sum(node=%016p, l=%d, r=%d): "
			"node->valid_val, "
			"returning (node->r=%d - node->l=%d) * "
			"node->val=%lld\n",
			node, l, r, node->r, node->l, node->val);*/
		return (r - l + 1) * node->val; /* XXX */
	}
	return sum(node->left, l, MIN(r, node->left->r)) +
		sum(node->right, MAX(l, node->right->l), r);
}

/* K&R */
void
treeprint(Node *p, FILE* fp)
{
	if (p != NULL) {
		treeprint(p->left,  fp);
/*		(void) fprintf(fp, "%6d-%6d:%*s"
				"val=%7lld sum=%7lld valid_val=%5s\n",
				p->l, p->r, 0, " ", p->val, p->sum,
				p->valid_val ? "true" : "false");*/
		/*treeprint(p->right, fp);*/
	}
}

void
free_tree(Node *node)
{
	if (node->l != node->r) {
		free_tree(node->left);
		free_tree(node->right);
	}
	free(node);
}

int
main(void)
{
	int n;
	Node *root;
	int cmd, a, b;
	long long x;

	root = init(0, (int) 1e+5); /* - 9,600,048 bytes from ur RAM */

	(void) scanf("%d", &n);
	while (scanf("%d", &cmd) == 1) {
		if (cmd == 0) {
			/* set */
			(void) scanf("%d%d%lld", &a, &b, &x);
			set(root, a, b, x);
		} else if (cmd == 1) {
			/* sum */
			(void) scanf("%d%d", &a, &b);
			(void) printf("%lld\n", sum(root, a, b));
		} else
			(void) fprintf(stderr, "unkn cmd \"%d\"\n", cmd);
		treeprint(root, stderr);
	}
	free_tree(root);
	return 0;
}
